<?php session_start(); ?>
<?php
 if(!$_SESSION['uname']){
  echo "你没有权限访问此页面!";
  return false;
}
?>
<?php include("../inc/db_config.inc"); ?>
<?php

if(isset($_REQUEST['links'])&&$_REQUEST['links']!=""){
    $blog_url=$_REQUEST['links'];
}else{
    echo "博客地址不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}
if(isset($_REQUEST['cata'])&&$_REQUEST['cata']!=""){
    $blog_cata=$_REQUEST['cata'];
}else{
    echo "分类不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}

if(isset($_REQUEST['title'])&&$_REQUEST['title']!=""){
   // $blog_title=$_REQUEST['title'];
    if (get_magic_quotes_gpc()) {
			//$notice_cont = addslashes($_REQUEST['content']);
			$blog_title =  stripslashes(trim($_REQUEST['title']));
		} else {
			$blog_title = trim($_REQUEST['title']);
		}
		$blog_title = str_replace('\'', "''", $blog_title);
}else{
    echo "博客标题不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}
if(isset($_REQUEST['description'])&&$_REQUEST['description']!=""){
    //$blog_desc=$_REQUEST['description'];
    if (get_magic_quotes_gpc()) {
			//$notice_cont = addslashes($_REQUEST['content']);
			$blog_desc =  stripslashes(trim($_REQUEST['description']));
		} else {
			$blog_desc = trim($_REQUEST['description']);
		}
		$blog_desc = str_replace('\'', "''", $blog_desc);
}
$blog_zid=$_REQUEST['z_zid'];
$blog_sid=$_REQUEST['z_sid'];
$blog_ps=$_REQUEST['z_ps'];
$blog_contact=$_REQUEST['contact'];
date_default_timezone_set("Asia/Shanghai"); //北京时间
$blog_created=date("Y-m-d H:i:s");
//echo "insert into link (url,name,desc,created) values('$link_url','$link_title','$link_desc','$link_created')";
$result_post=mysql_query("insert into blogs (title,cata,description,links,addTime,contact,z_zid,z_sid,z_ps) values('$blog_title','$blog_cata','$blog_desc','$blog_url','$blog_created','$blog_contact','$blog_zid','$blog_sid','$blog_ps')");
if(mysql_affected_rows()>0){
    $ref=$_SERVER['HTTP_REFERER'];
    echo "添加成功!页面会在1秒钟后自动返回.<script type='text/javascript'>setTimeout(function(){window.location.href='$ref'},1000)</script>";
}else{
    echo "添加失败!<a href='javascript:history.back()'>返回</a>";
}
 ?>